package game.efficientCollisionPrediction;

import java.util.ArrayList;
import java.util.Collection;

import game.SpaceObject;

public class FutureBoundaryCollision extends FutureCollision {

	private final SpaceObject object;
	
	public FutureBoundaryCollision(SpaceObject object) throws IllegalStateException {
		this.object = object;
		if(isTerminated()) 
			throw new IllegalStateException();
		
		update();
	}

	@Override
	public Collection<SpaceObject> getInvolvedSpaceObjects() {
		Collection<SpaceObject> list = new ArrayList<SpaceObject>();
		list.add(getObject());
		return list;
	}
	
	@Override
	public double getTimeToCollision() {
		if(isTerminated())
			return Double.POSITIVE_INFINITY;
		return getObject().getTimeToBoundary();
	}

	public SpaceObject getObject() {
		return this.object;
	}
	
	@Override
	public boolean isTerminated() {
		return getObject().isTerminated();
	}
	
	public void collide() {
		getObject().hitBoundary();
	}
}
